home *** CD-ROM | disk | FTP | other *** search
- /* ======================================================================
- DESC: Intro Graph Feature Called from RpmIntro.asp
-
- PLATFORMS: >= MS IE 4.0
- USAGE NOTES:
- ====================================================================== */
-
-
- // Process Request from Intro Page to Show Graph of Local PC
- var IgItem = null; // Group Handle
- var Ic = null; // Computer name
- var IcItem = null; // Computer Handle
- var Io = null; // Object Name
- var IoItem = null; // Object Handle
- var Icnt = null; // Counter Name
- var IcntItem = null; // Counter Handle
- var CMo = null; // Computer Serach Type
- var CItem = null; // Item Handle
- var IntroGraphO = null; // Intro Graph Object
- var IntroGraphStateF = 0; // Intro Graph State flag
- var ProcPerfChecked = false; // processor performance Monitoring should be reset
- var InvEventExpected = null;
-
- var NTProcObject = "Processor 0";
- var NTProcCntrName = "% Processor Time";
- var ProcObject98 = "Kernel";
- var ProcCntrName98 = "Processor Usage (%)";
- var ProcCntrName = null;
- var SB_RIGHT = 7; // Scroll Bar set for chart
- var State6Retry = 0;
-
- // Tree Serach definitions
- var Expand = 2;
- var Collapse = 1;
- var Root = 0;
- var FirstVisible = 5;
- var Next = 1;
- var Child = 4;
- var Caret = 9;
- var Tree = null;
-
- function processIntroGraphMode() {
- Tid = null; // reset
- // Process based on State flag
- switch ( IntroGraphStateF ) {
-
- case 0 : // Initial Entry
- if ( top.banner.IntroGraphMode == false )
- return;
- top.banner.IntroGraphMode = false; // reset
- top.main.restoreReduced(); // insure Tree pane is reduced in size
- top.main.TreePane.InventoryEventHandling = true; // Enable Tree Inventory Event handler
- Tree = top.main.TreePane.document.all.RPMTree; // Tree object
- top.Rstatus.Pstat("Searching for Local Computer '"+top.banner.IntroGraphAgentName+"' in Network Tree");
- case 1 :
- if ( IntroGraphStateF == 0 ) {
- stat = Tree.GetNextItem(1,0,Root); // Get First Group
- top.Rstatus.Pstat("Group: "+stat);
- if ( stat == "Disconnected" || stat == "No Groups" ) {
- break;
- }
- }
- else {
- Tree.GetNextItem(1,IgItem,Next); // Get Next Group
- }
- if ( (IgItem = Tree.CurItem) == 0 ) { // Handle to Group; if not found, tell user
- alert("Cannot find Local Computer '"+top.banner.IntroGraphAgentName+"' in Network Tree");
- IntroGraphStateF = 0;
- }
- else {
- InvEventExpected = IntroGraphStateF = 90; // Set State flag; wait for Event
- Tree.ExpandItem(1,IgItem,Expand); // Expand Group to Computers
- CMo = Child; CItem = IgItem; // Set to get first computer in Group
- }
- break;
-
- case 90 : // Group Expanded Event
- IntroGraphStateF = 2; // Delay before processing Computers
- break;
-
- case 2: // Group Expnaded, Look at each Computer in Group for Match
- for ( ; CItem != 0; ) { // Look at Computers in the Group
- Ic = Tree.GetNextItem(1,CItem,CMo); // Next Computer in Group
- CItem = IcItem = Tree.CurItem; // Handle to Local Computer
- CMo = Next; // Get Next
- if ( Ic == top.banner.IntroGraphAgentName ) { // if found
- break;
- }
- }
- if (IcItem == 0 ) { // if Computer not found
- Tree.ExpandItem(1,IgItem,Collapse); // Collapse this Group, get Next Group
- IntroGraphStateF = 1; // Set State flag
- }
- else {
- Tree.Selectitem(1,IcItem,Caret); // Highlight Computer
- if ( !Tree.CurConnected ) { // if not connected
- Tree.SetConnected(1,IcItem,true); // tell it to connect
- }
- top.Rstatus.Pstat("Found Local Computer: '"+top.banner.IntroGraphAgentName+"'");
- InvEventExpected = IntroGraphStateF = 91; // Set State flag; wait for Event
- Tree.ExpandItem(1,IcItem,Expand); // Expand Computer to Objects
- CMo = Child; CItem = IcItem; // Set to get first Object in Computer
- }
- break;
-
- case 91 : // Find Processor Object to Monitor
- for ( ; CItem != 0; ) { // Look at Objects in the Computer
- getNextObject(); // get next Object
- if ( Io == ProcObject98 ) {
- ProcCntrName = ProcCntrName98;
- break;
- }
- else if ( Io == NTProcObject ) {
- ProcCntrName = NTProcCntrName;
- break;
- }
- }
- if ( IoItem == 0 ) { // if Object not found
- IntroGraphStateF = 0; // ReSet State flag
- alert("Cannot find Object to Graph");
- }
- else {
- Tree.Selectitem(1,IoItem,Caret); // Highlight Object
- top.Rstatus.Pstat("Found Processor Object");
- InvEventExpected = IntroGraphStateF = 92; // Set State flag; wait for Event
- ExpandObject(); // Expand Object to Counters
- }
- break;
-
- case 92 : // Find Processor Counters to Monitor
- for ( ; CItem != 0; ) { // Look at Counters in the Objects
- getNextCounter(); // get next Counter
- if ( Icnt == ProcCntrName ) { // if found
- Tree.Selectitem(1,IcntItem,Caret); // Select it for add to the Chart
- Tree.SetChecked(1,IcntItem,true); // check it for monitoring
- ProcPerfChecked = true; // flag to reset on exit from View Charts
- break;
- }
- }
- if (IcntItem == 0 ) { // if Counter not found
- IntroGraphStateF = 0; // ReSet State flag
- alert("Cannot find Counter to Graph");
- }
- else {
- top.Rstatus.Pstat("Found Processor Performance Counter");
- IntroGraphStateF = 5; // Set State flag
- }
- break;
-
- case 5 : // See If Graph Already Exists and if so Open it
- top.Rstatus.Pstat("Searching for Existing Local Computer Chart");
- top.banner.DemoMode = true; // indicate in Demo mode
- ChartOpenName = top.banner.IntroGraphAgentName+" Processor Performance";
- OpenBkMrk = 9998; // Return here via "processViewChartsBookmarks()" if Open succeeds
- ChartNotFoundBid = 9999; // Return here via "processViewChartsBookmarks()" if Open fails
- IntroGraphStateF = 0; // ReSet State flag
- doButtonProcessing("Open");
- break;
-
- case 9998 : // Graph for Local Agent Already Exists and is now Open
- State6Retry = 0; // reset retry count
- case 6 :
- if ( FullViewChartName == null ) {
- IntroGraphStateF = 0; // reset IntroGraph Mode if active
- top.banner.IntroGraphMode = false;
- return;
- }
- IntroGraphO = document.all["RpmGrph"+FullViewChartName]; // Selected Graph Object
- // Wait until Chart has been loaded before moving on
- ++State6Retry; // bump retry counter
- if ( document.all[FullViewChartName].HData == true ) { //|| State6Retry > 20) {
- IntroGraphStateF = 10; // Set State flag
- doButtonProcessing("Add"); // insure Performance counter is on the Chart
- }
- else {
- IntroGraphStateF = 6; // Set State flag
- }
- break;
-
- case 9999 : // Existing Graph for Local Agent not Found
- top.Rstatus.Pstat("Creating New Chart for Local Computer");
- IntroGraphStateF = 7; // Delay before Creating New Graph
- break;
-
- case 7 : // Create New Graph
- IntroGraphStateF = 8; // Set State flag
- doButtonProcessing("New");
- break;
-
- case 8 : // Add Counters and Set Name
- IntroGraphO = document.all["RpmGrph"+FullViewChartName]; // Selected Graph Object
- IntroGraphO.SetGraphName(top.banner.IntroGraphAgentName+" Processor Performance");
- IntroGraphStateF = 6; // Set State flag
- doButtonProcessing("Add");
- break;
-
- case 10 : // Set Slider on Chart to Right for Current Time
- top.Rstatus.Pstat("Local Performance Chart Named: '"+top.banner.IntroGraphAgentName+" Processor Performance'");
- IntroGraphStateF = 11; // Set State flag
- IntroGraphO.SetHScrollPos(SB_RIGHT); // set slider tab
- break;
-
- case 11 : // Start Play
- doButtonProcessing("Play");
- IntroGraphStateF = 0; // ReSet State flag
- top.main.TreePane.InventoryEventHandling = false; // Disable Tree Inventory Event handler
- break;
- }
- if ( IntroGraphStateF != 0 && IntroGraphStateF < 90) { // Set T/O for Reentry
- Tid = setTimeout("processIntroGraphMode()",3000); // Delay 3 secs
- }
- }
-
- // Get Next Object for Computer
- function getNextObject() {
- Io = Tree.GetNextItem(1,CItem,CMo); // Next Object in Computer
- CItem = IoItem = Tree.CurItem; // Handle to Object
- CMo = Next; // Get Next
- }
-
- // Expand Object to Show Counters
- function ExpandObject() {
- Tree.ExpandItem(1,IoItem,Expand); // Expand Object to Counter
- CMo = Child; CItem = IoItem; // Set to get first Counter in Object
- }
-
- // Get Next Counter for Object
- function getNextCounter() {
- Icnt = Tree.GetNextItem(1,CItem,CMo); // Next Counter in Object
- CItem = IcntItem = Tree.CurItem; // Handle to Counter
- CMo = Next; // Get Next
- }
-
- // Process the Tree Inventory Event as a Result of Expand() on a Group, Computer or Object
- function processTreeInventoryEvent() {
- if ( InvEventExpected != 0 ) { // if expected
- InvEventExpected = null; // reset expected
- //Delay 1/2 second then start processing of the expansion; allow time for all the expanded items to download
- Tid = setTimeout("processIntroGraphMode()",500); // Delay 500 ms
- }
- }
-
-